	define(['vue','moment','config','common','../model/upLoadList','../model/downLoadList','numeral'],
	function(Vue,moment,config,utils,upLoadList,downLoadList,numeral){
	'use strict';

	var PointsDetailView = new Vue({
		el:'#app',
		data:{
			list:'',	
			page: 1,
			totalPage:0,
			isLoadMore:0,
			pageSize:'',
			userTypeId:'',
			integralB:'',
			integralA:''
		},
		filters: {
		  moment: function (date) {
		    return moment(date*1000).format('MM-DD');
		  },
		  numeral: function(value){
		  	var string = numeral(value*1).format('0,0.00');
		  	return string;
		  },
		  maxlen: function (value) {
		  	if(value!==null){
		  		if(value.length > 6){
		  			return value.slice(0,6) + '...';
			  	}else{
			  		return value;
			  	}
		  	} 	
		  },
		  integral: function(value){
		  		if(value){
		  			return value;
		  		}else{
		  			return 0;
		  		}
		  }
		},
		watch:{
			list: function(to,from){
				if(to.length == 0){
					$('.error404').show();
				}
			}
		},
		created:function(){	
			var _this=this;
			_this.userTypeId =utils.getData('userTypeId');
			if(this.userTypeId == 5 && window.location.href.match("PointsDetail.html")){
				window.location.href='PointsDetail_firm.html';
			}else if(this.userTypeId == 4 && window.location.href.match("PointsDetail_firm.html")){
				window.location.href='PointsDetail.html';
			}
			//_this.pageSize = parseInt(Math.ceil(($('body').height()-126)/32), 10);
			_this.pageSize = 30;
			var data = {
				page: _this.page,
				pageSize: _this.pageSize,
			}
			upLoadList.ajax(utils.getWebUrl('integralRecord/list'),data,function(res){
				_this.integralA = res.data.integralA;
				_this.integralB = res.data.integralB;
				_this.list = res.data.data.list;
				_this.totalPage = res.data.data.totalPage;
				//_this.page++;
			})
		},
		directives: {
		  scroll: {
		    bind: function (el, binding){
		      window.addEventListener('scroll',function() {
		       		var fnc = binding.value;   
   					fnc();
		      })
		    }
		  }
		},
		methods:{
			loadMore:function(event){
				var _this = this;
				//console.log(upLoadList.getScrollTop()+upLoadList.getClientHeight(),upLoadList.getScrollHeight(),_this.page,_this.totalPage)
				if ((upLoadList.getScrollTop() + upLoadList.getClientHeight() >= upLoadList.getScrollHeight())&&_this.page<_this.totalPage) {

		            _this.page = _this.page+1;
		            var data = {
						page: _this.page,
						pageSize: _this.pageSize,
						integralType:1
					}
					
					upLoadList.ajax(utils.getWebUrl('integralRecord/list'),data,function(res){
						
						_this.list = _this.list.concat(res.data.data.list);
						_this.totalPage = res.data.data.totalPage;
						_this.integralA = res.data.integralA;
						_this.integralB = res.data.integralB;

					})
		        }
			}
		}
	});
	return PointsDetailView
});
